<template>
  <div class="nav">
    <el-row class="tac2">
      <el-col :span="24">
        <el-menu
            :router="true"
            default-active="this.$router.path"
            @open="handleOpen"
            @close="handleClose"
            background-color="#545c64"
            text-color="#fff"
            active-text-color="#ffd04b"
            unique-opened="true">



          <el-menu-item  index="/">
            <template slot="title">
              <i class="el-icon-view"></i>
              <span>首页</span>
            </template>
          </el-menu-item>


          <el-submenu index="1" :disabled="login">
            <template slot="title">
              <i class="el-icon-user"></i>
              <span>我的</span>
            </template>
            <el-menu-item-group>
              <!-- <router-link index="1-1" to="/login">查看用户个人信息</router-link> -->
              <el-menu-item index="/userInfo">个人信息</el-menu-item>
              <el-menu-item index="shoppingCart">购物车</el-menu-item>
              <el-menu-item index="/order">我的订单</el-menu-item>
            </el-menu-item-group>
          </el-submenu>



          <el-submenu index="2" :disabled="status">

            <template slot="title">
              <i class="el-icon-magic-stick"></i>
              <span>管理员</span>
            </template>
            <el-menu-item-group>
              <!-- <router-link index="1-1" to="/login">查看用户个人信息</router-link> -->

                <el-menu-item index="stock">库存管理</el-menu-item>
                <el-menu-item index="Add">商品入库</el-menu-item>
                <el-menu-item index="orderList">用户订单</el-menu-item>
                <el-menu-item index="userList">用户信息</el-menu-item>
                <el-menu-item index="dataAnalysis">数据分析</el-menu-item>
            </el-menu-item-group>
          </el-submenu>


          <el-submenu index="3">
            <template slot="title">
              <i class="el-icon-menu"></i>
              <span>账号</span>
            </template>
            <el-menu-item-group>
              <!-- <router-link index="1-1" to="/login">查看用户个人信息</router-link> -->
              <el-menu-item index="/login">登录</el-menu-item>
              <el-menu-item index="/regist">注册</el-menu-item>
            </el-menu-item-group>
          </el-submenu>
        </el-menu>
      </el-col>
    </el-row>
  </div>
</template>

<script>
export default {
  name: 'LeftNav',
  data() {
    return {
      status:sessionStorage.getItem('user')==null?true:JSON.parse(sessionStorage.getItem('user')).status,
      login:sessionStorage.getItem('user')==null?true:false
    }
  },
  methods: {
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    }
  }
}
</script>

<style lang="css">
.nav {
width: 100%;
}


.tac2{
   width: 100%;
 }



</style>
